package com.meeting_test.meeting_test.entrance.web;

import com.vs.debug.stack.agent.LogStackContextInvokeRecorder;
import com.vs.debug.stack.agent.MethodVisitorHandlerFilter;
import com.vs.debug.stack.agent.StackContextInvokeRecorder;
import com.vs.debug.stack.config.EnableVSReplayConfiguration;
import com.vs.sqlmapper.spring.DataSourceConfig;
import com.vs.sqlmapper.spring.scan.VSDaoBeanScan;
import com.vs.mock.config.EnableVSMockConfiguration;
import com.vs.sqlmapper.spring.express.EnableVSMockExpress;
import com.vs.agent.TocoAgentInitializer;


import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@SpringBootApplication(scanBasePackages = {"com.meeting_test", "com.vs"})
@VSDaoBeanScan(basePackages = {"com.vs","com.meeting_test"})
@Import(DataSourceConfig.class)
@EnableVSReplayConfiguration
@EnableVSMockConfiguration
@EnableVSMockExpress
@MapperScan("自定义mapper包")
public class AppApplication{

//    @Bean(name = "stackContextInvokeRecorder")
//    public StackContextInvokeRecorder createStackContextInvokeRecorder() throws Exception {
//        return new LogStackContextInvokeRecorder(); // 可以根据需求扩展实现
//    }

    @Bean
    public MethodVisitorHandlerFilter createMethodVisitorHandlerFilter() {
        StackContextInvokeRecorder stackContextInvokeRecorder = new LogStackContextInvokeRecorder();
        return new MethodVisitorHandlerFilter(stackContextInvokeRecorder);
    }

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(AppApplication.class);
        application.addInitializers(new TocoAgentInitializer());
        application.run(args);
    }
}
